package com.stockz.indicator.value;

import java.util.List;

import com.stockz.core.model.Bar;
import com.stockz.core.util.BarUtil;
import com.stockz.core.util.BarUtil.BarValueType;
import com.stockz.core.util.ListUtil;
import com.stockz.indicator.Indicator;

public class ValueIndicator implements Indicator<Object> {
	
	private BarValueType barValueType = BarValueType.AVGTRADESIZE;
	
	@Override
	public double getValue(List<Bar> barList) {
		if(barList == null || barList.isEmpty())
			return 0;
		else
			return BarUtil.getValue(barList.get(0),getBarValueType());
	}
	
	@Override
	public Object getIndicatorConfiguration() {
		return null;
	}

	@Override
	public BarValueType getBarValueType() {
		return barValueType;
	}

	@Override
	public void setBarValueType(BarValueType barValueType) {
		this.barValueType = barValueType;
	}

	@Override
	public double[] getValues(List<Bar> barList) {
		return ListUtil.convert(barList, barValueType);
	}
}
